#include "junix.h"

int main(int argc, char **argv)
{
	char buf[LINE_MAX];

	FILE *fp = fopen("/dev/pts/4","w+");
	if(!fp)
		err_quit("fopen error");

    if( fgets(buf, LINE_MAX, fp) != NULL)
		if (fputs(buf, stdout)==EOF)
			err_quit("fputs");

	while( fgets(buf,LINE_MAX,stdin) != NULL)
		if( fputs(buf, fp) == EOF)
			err_quit("fputs");

	if( ferror(fp) )
		err_quit("ferror");

	if( fcloseall() == EOF)
		err_quit("fclose");

	exit(0);
}

